{include "header.tpl"}
<form id="configForm" rel="ajax" method="post" action="/website/config" enctype="multipart/form-data" class="form-horizontal" role="form">

    <div class="form-group form-group-sm">
        <label for="" class="col-sm-3 control-label">首单优惠(元):</label>
        <div class="col-sm-5">
            <input type="text" id="first_reduce_money" name="first_reduce_money" value="{$data.first_reduce_money}" class="form-control" required/>
        </div>
    </div>

    <div class="form-group form-group-sm">
        <label class="col-sm-3 control-label" for="">起送价格(元):</label>
        <div class="col-sm-5">
            <input type="text" id="price_send" name="price_send" value="{$data.price_send}" class="form-control" required/>
        </div>
    </div>

    <div class="form-group form-group-sm">
        <label class="col-sm-3 control-label" for="">配送距离(KM):</label>
        <div class="col-sm-5">
            <input type="text" id="distance" name="distance" value="{$data.distance}" class="form-control" required/>
        </div>
    </div>

    <div class="form-group form-group-sm">
        <label class="col-sm-3 control-label" for="">提示语:</label>
        <div class="col-sm-5">
            <input type="text" id="cue_words" name="cue_words" value="{$data.cue_words}" class="form-control" required/>
        </div>
    </div>

    <div class="form-group form-group-sm">
        <label class="col-sm-3 control-label" for="">店铺打烊提示语:</label>
        <div class="col-sm-5">
            <input type="text" id="store_close_words" name="store_close_words" value="{$data.store_close_words}" class="form-control" required/>
        </div>
    </div>

    <div class="form-group form-group-sm">
        <label class="col-sm-3 control-label" for="">底部提示语:</label>
        <div class="col-sm-5">
            <input type="text" id="btm_cue_words" name="btm_cue_words" value="{$data.btm_cue_words}" class="form-control" required/>
        </div>
    </div>

    <div class="form-group form-group-sm">
        <label class="col-sm-3 control-label" for="">满减优惠:</label>
        <div class="col-sm-5">
            <table class="fTable" id="reduceTable" style="width: 100%;">
                <thead>
                    <th>金额(元)</th>
                    <th>优惠(元)</th>
                    <th width="100">操作</th>
                </thead>
                <tbody>
                    {if $full_discount}
                    {foreach from=$full_discount item=item}
                        <tr>
                            <td>满 <input type="text" name="pay_money[]" value="{$item.pay_money}" required/></td>
                            <td>减 <input type="text" name="reduce_money[]" value="{$item.reduce_money}" required/></td>
                            <td><a href="javascript:;" class="del">删除</a></td>
                        </tr>
                    {/foreach}
                    {else}
                        <tr>
                            <td>满 <input type="text" name="pay_money[]" required/></td>
                            <td>减 <input type="text" name="reduce_money[]" required/></td>
                            <td><a href="javascript:;" class="del">删除</a></td>
                        </tr>
                    {/if}
                    <tr>
                        <td colspan="3" style="text-align: right"><a class="btn btn-success" id="btn-add">添加</a></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="form-group form-group-sm">
        <label for="" class="col-sm-3 control-label">&nbsp;</label>
        <div class="col-sm-3">
            <input type="hidden" name="id" value="{$smarty.get.id}"/>
            <button type="submit" class="btn btn-primary">提交</button>
        </div>
    </div>
</form>
<script>
    $(function () {
        $('#btn-add').click(function () {
            $(this).closest('tr').before('<tr>' +
                                                '<td>满 <input type="text" name="pay_money[]" required/></td>' +
                                                '<td>减 <input type="text" name="reduce_money[]" required/></td>' +
                                                '<td><a class="del">删除</a></td>' +
                                            '</tr>');
        });
        $(document).on('click','.del',function(){
            var tr = $(this).closest('tr');
            layer.confirm('确定是否删除',{
                btn: ['确定','取消'] //按钮
            },function() {
                tr.remove();
                layer.msg('删除成功');
            });
        });
    });
</script>
{include "footer.tpl"}